package com.witte.controller;

import com.witte.entity.Achievement;
import com.witte.entity.Product;
import com.witte.entity.RespBean;
import com.witte.service.AchievementService;
import com.witte.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
@RequestMapping("/api/Sales")
@CrossOrigin
public class AchievementController {
    @Autowired
    AchievementService achievementService;
    @Autowired
    ProductService productService;
    @GetMapping(value="achievement/getAchievement")
    public RespBean getNameList(String name ){
        //System.out.println("111");
    	Map<String ,List<Object>> ret =achievementService.getMapByProductName(name);
        RespBean respBean=RespBean.error("新增错误");
        if(ret!=null) {
            respBean = RespBean.ok("ok", ret);
        }
        return respBean;
    }

    @GetMapping(value = "achievement/getStateList")
    public RespBean getStateList(Integer beginPage, Integer pageSize) {
        List<Product> list = productService.getListForPage(beginPage, pageSize);
        RespBean respBean = RespBean.error("新加错误！");
        if (list != null) {
            respBean = RespBean.ok("ok", list);
            respBean.setTotleSize(productService.getRecodeCount());
        }
        return respBean;
    }
/*    @GetMapping(value="/getStateList")
    public RespBean getStateList(Integer beginPage,Integer pageSize){
        // System.out.println("111");
        List<Product> list=productService.getListForPage(beginPage,pageSize);
        RespBean respBean=RespBean.error("新加错误！");
        if(list!=null) {
            respBean=RespBean.ok("ok",list);
            respBean.setTotleSize(productService.getRecodeCount());
        }
        return respBean;
    }*/


}
